<?php
require_once( 'classes/mofachi.User.php' );
session_start();
if( isset($_POST[ "eml" ]) && isset($_POST[ "pwd" ]) ) {
	$isLogin = User::authenticate( $_POST[ "eml" ], $_POST[ "pwd" ] );
	if( $isLogin ) {
		$user = new User();
		$user->email = $_POST[ "eml" ];
		$user->loadInfoByEmail();

		$_SESSION[ 'user' ] = $user;
		$_SESSION[ 'babies' ] = $user->getBabies();
	} else {
		header("Location: index.htm");
	}
} else if( !isset($_SESSION[ 'user' ]) ) {
	header("Location: index.htm");
}
?>